package com.test.stream;

import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * @Description:
 * @Author: yangzhiwei
 * @Date: 2021/3/2 14:33
 */
public class StreamTest2 {
    public static void main(String[] args) {
//        List<FyBuildingHouseDetailDto> detailList = new ArrayList<>();
//        FyBuildingHouseDetailDto house = new FyBuildingHouseDetailDto();
//        FyBuildingHouseDetailDto house1 = new FyBuildingHouseDetailDto();
//        house.setTotalPrice(1.1);
//        house1.setTotalPrice(2.2);
//        detailList.add(house);
//
//        detailList.add(house1);
//        double totalPrice = detailList.stream().mapToDouble(FyBuildingHouseDetailDto::getTotalPrice).sum();
//        System.out.println(totalPrice);
//
//        house.setState(2);
//        house1.setState(3);
//        int soldGoodsNumber = (int)(detailList.stream().filter(FyBuildingHouseDetailDto -> FyBuildingHouseDetailDto.getState() == 3 ).count());
//
//        System.out.println(soldGoodsNumber);
//        double soldGoodsAmount  = detailList.stream()
//                .filter(fyBuildingHouseDetailDto -> {return fyBuildingHouseDetailDto.getState() == 3;})
//                .mapToDouble(FyBuildingHouseDetailDto::getTotalPrice).sum();
//        System.out.println(soldGoodsAmount);
        //detailList.stream().forEach(fyBuildingHouseDetailDto -> {fyBuildingHouseDetailDto.setState(1);});
        User user = new User();
        user.setId( 1 == 3 ? 1 : 0);
        System.out.println(user.getId());

        DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        String s  = "2021-03-05 00:00:00.0";
        String sub = s.substring(0, 19);
        System.out.println(sub);
        LocalDateTime date = LocalDateTime.parse(sub,formatter);
        System.out.println(date);
        System.out.println(date.compareTo(LocalDateTime.now()));
    }
}
